import React,{useState}from 'react'
import {Navigate} from 'react-router-dom'

export default function Home() {
    const [sum,setSum]=useState(1)
    function addSum(){
        setSum(2)
    }
  return (
    <div>
        <h3>我是Home组件</h3>
        {sum===2? <Navigate to='/about'  /> : <h4>当前sum的值为:{sum}</h4>}
       
        <button onClick={addSum}>点击我sum变为2</button>
    </div>
  )
}
